package creation.factory.method;

enum OrderType {
    bJType,
    lDType
}

class OrderPizza {
    Pizza createPizza(OrderType orderType,String name){
        Pizza pizza = null;
        if(orderType==OrderType.bJType){
            pizza = new BJOrderPizza().orderPizza(name);
        }else if(orderType==OrderType.lDType) {
            pizza = new LDOrderPizza().orderPizza(name);
        }

        if(pizza != null){
            pizza.prepare();
            pizza.baker();
            pizza.cut();
            pizza.box();
        }
        return pizza;
    }
}

class BJOrderPizza {
    Pizza orderPizza(String name){
        Pizza pizza = null;
        switch (name){
            case "chess":
                pizza = new BJChessPizza();
                break;
            case "greek":
                pizza = new BJGreekPizza();
                break;
        }
        return pizza;
    }
}
class LDOrderPizza {
    Pizza orderPizza(String name){
        Pizza pizza = null;
        switch (name){
            case "chess":
                pizza = new LDChessPizza();
                break;
            case "greek":
                pizza = new LDGreekPizza();
                break;
        }
        return pizza;
    }
}
